<!--
 * @Author: lwHao
 * @Date: 2020-12-19 14:33:58
 * @LastEditors: lwHao
 * @LastEditTime: 2020-12-19 16:51:35
-->
<template>
  <div>
    <el-form label-width="120px">
      <el-form-item label="名称">
        <el-input v-model="category.name"></el-input>
      </el-form-item>
      <el-form-item label="排序">
        <el-input-number v-model="category.sort"></el-input-number>
      </el-form-item>
      <el-form-item>
        <el-button @click="$emit('cancel')">取消</el-button>
        <el-button type="primary" @click="onSubmit">确认</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import Vue from 'vue'
import { saveOrUpdateResourceCategories } from '@/services/resource-category'

export default Vue.extend({
  name: 'CreateOrEditResource',
  props: {
    category: Object
  },
  methods: {
    async onSubmit () {
      await saveOrUpdateResourceCategories(this.category)
      this.$message.success(this.category.id ? '修改成功' : '操作成功')
      this.$emit('success')
    }
  }
})
</script>

<style>

</style>
